package com.varian.auth.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.varian.mybatis.base.PrimaryKeyEntity;
import com.varian.tool.enums.CommonStatusEnum;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * OAuth2客户端信息
 *
 * @author ben
 * @since 2024/6/27
 */
@Data
@TableName(value = "oauth2_registered_client", autoResultMap = true)
public class OAuth2RegisteredClient extends PrimaryKeyEntity {
    /**
     * 客户端id
     */
    private String clientId;
    /**
     * 客户端id发放时间
     */
    private LocalDateTime clientIdIssuedAt;
    /**
     * 密钥
     */
    private String clientSecret;
    /**
     * 密钥过期时间
     */
    private LocalDateTime clientSecretExpiresAt;
    /**
     * 客户端名称
     */
    private String clientName;
    /**
     * 认证方式
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> clientAuthenticationMethods;
    /**
     * 授权类型
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> authorizationGrantTypes;
    /**
     * 重定向URI
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> redirectUris;
    /**
     * 登出后重定向URI
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> postLogoutRedirectUris;
    /**
     * 授权范围
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<String> scopes;
    /**
     * 客户端设置
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> clientSettings;
    /**
     * 令牌设置
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> tokenSettings;
    /**
     * 状态
     */
    private CommonStatusEnum clientStatus;
    /**
     * 版本
     */
    @Version
    private Integer version;
    /**
     * 删除标记
     */
    @TableField("is_deleted")
    @TableLogic(value = "0", delval = "1")
    private Boolean deleted;
}
